using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lesson8 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        //无参触发
        ListenerMgr.GetInstance().AddTrigger("EnterGame", EnterGame);
        //有参触发
        ListenerMgr.GetInstance().AddTrigger<int>("onTrigger1", onTrigger1);
        ListenerMgr.GetInstance().AddTrigger<string>("onTrigger2", onTrigger2);
        ListenerMgr.GetInstance().AddTrigger<List<int>>("onTrigger3", onTrigger3);
        Invoke(nameof(DelayedMethod), 3f);
    }

    void DelayedMethod()
    {
        ListenerMgr.GetInstance().Trigger("EnterGame");
        ListenerMgr.GetInstance().Trigger("onTrigger1", 100);
        ListenerMgr.GetInstance().Trigger("onTrigger2", "Hello World");
        ListenerMgr.GetInstance().Trigger("onTrigger3", new List<int> { 1,2,3,4,5,6,7,8,9,10 });
    }

    void EnterGame()
    {
        Debug.LogFormat("");
    }

    void onTrigger1(int val)
    {
        Debug.LogFormat("[Lesson8][onTrigger1] val:{0}", val);
    }

    void onTrigger2(string val)
    {
        Debug.LogFormat("[Lesson8][onTrigger2] val:{0}", val);
    }

    void onTrigger3(List <int> vals)
    {
        Debug.LogFormat("[Lesson8][onTrigger3] vals:{0}", vals.Count);
    }
}
